package jj.fly.activiti.leavebill.utils;

import jj.fly.activiti.leavebill.domain.Employee;
import jj.fly.activiti.leavebill.service.IEmployeeService;
import org.activiti.engine.delegate.DelegateExecution;
import org.activiti.engine.delegate.DelegateTask;
import org.activiti.engine.delegate.JavaDelegate;
import org.activiti.engine.delegate.TaskListener;
import org.springframework.beans.BeansException;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.ApplicationContext;
import org.springframework.context.ApplicationContextAware;
import org.springframework.stereotype.Component;

import javax.annotation.PostConstruct;
import javax.servlet.http.HttpSession;

/**
 * Author: jiangjun
 * Date: 2018/5/8
 * Time: 下午3:03
 * Description:
 */
//@Component
public class ManagerTaskHandler implements TaskListener {

//    @Autowired
//    private HttpSession session;

    private ApplicationContext applicationContext;

    @Autowired
    private IEmployeeService employeeService;


    @Override
    public void notify(DelegateTask delegateTask) {
        IEmployeeService employeeService = applicationContext.getBean(IEmployeeService.class);
        Employee manager = employeeService.getDataById(1);
//        Employee employee = (Employee) session.getAttribute("current_user");
//        Employee manager = employeeService.getDataById(employee.getManagerId());
        // 设置个人任务的办理人
        delegateTask.setAssignee(manager.getName());

    }
}
